package com.lzy.mall.ware.controller;


import cn.hutool.core.collection.CollUtil;
import com.lzy.mall.common.utils.PageUtils;
import com.lzy.mall.common.utils.ResultUtils;
import com.lzy.mall.ware.entity.WmsPurchaseDetail;
import com.lzy.mall.ware.entity.WmsWareOrderTask;
import com.lzy.mall.ware.service.WmsWareOrderTaskService;
import org.springframework.web.bind.annotation.*;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Map;

/**
 * 库存工作单(WmsWareOrderTask)表控制层
 *
 * @author lzy
 * @since 2021-08-24 19:01:52
 */
@RestController
@RequestMapping("wareordertask")
@RequiredArgsConstructor(onConstructor_ = {@Autowired})
public class WmsWareOrderTaskController {
    private final WmsWareOrderTaskService wareOrderTaskService;

    @GetMapping("/list")
    public ResultUtils list(@RequestParam Map<String,Object> params){
        PageUtils page = wareOrderTaskService.queryPage(params);
        return ResultUtils.ok().put("page",page);
    }

    @RequestMapping("/info/{id}")
    //@RequiresPermissions("ware:wareinfo:info")
    public ResultUtils info(@PathVariable("id") Long id){
        WmsWareOrderTask wareOrderTask = wareOrderTaskService.getById(id);

        return ResultUtils.ok().put("wareOrderTask", wareOrderTask);
    }

    @PostMapping("/save")
    public ResultUtils save(@RequestBody WmsWareOrderTask wareOrderTask){
        wareOrderTaskService.save(wareOrderTask);
        return ResultUtils.ok();
    }

    @PostMapping("/update")
    public ResultUtils update(@RequestBody WmsWareOrderTask wareOrderTask){
        wareOrderTaskService.update(wareOrderTask);
        return ResultUtils.ok();
    }

    @PostMapping("/delete")
    public ResultUtils delete(@RequestBody Long[] ids){
        wareOrderTaskService.removeBatch(CollUtil.toList(ids));
        return ResultUtils.ok();
    }
}
